package com.xiaozhuai.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class RestFullController {

    //原来的:http://localhost:8080/springmvc_04_controller_war_exploded/add1?&a=1&b=1
    //现在的:http://localhost:8080/springmvc_04_controller_war_exploded/add1/1/1
    @RequestMapping("/add1")
    public String test1(int a, int b, Model model){
        int res = a + b;
        model.addAttribute("msg","结果为："+res);
        return "test";
    }

    @RequestMapping("/add2/{a}/{b}")
    public String test2(@PathVariable int a,@PathVariable int b, Model model){
        int res = a + b;
        model.addAttribute("msg","结果为："+res);
        return "test";
    }

    @RequestMapping("/add3/{a}/{b}")
    public String test3(@PathVariable int a,@PathVariable String b, Model model){
        String res = a + b;
        model.addAttribute("msg","结果为："+res);
        return "test";
    }
}
